import Cookies from "js-cookies/src/cookies";

const TokenKey = 'x-access-token';
const AccessTokenKey = 'x-access-token-auth';

const expriedTime = 30 * 24 * 60 * 60 * 1000; // 有效时间一个月
let inFifteenMinutes = new Date(new Date().getTime() + expriedTime);

export function setToken(token) {
    inFifteenMinutes = new Date(new Date().getTime() + expriedTime);
    return Cookies.setItem(TokenKey,token, { expires: inFifteenMinutes });
}

export function getToken() {
    return Cookies.getItem(TokenKey);
}

export function setAccessToken(assessToken) {
    inFifteenMinutes = new Date(new Date().getTime() + expriedTime);
    return Cookies.setItem(AccessTokenKey, assessToken, { expires: inFifteenMinutes });
}

export function getAccessToken(){
    return Cookies.getItem(AccessTokenKey);
}